const bubbleSort = (list) => {
  if (list.length <= 1) return list

  for (let i = list.length - 1; i > 0; i--) {
    for (let j = 0; j < i; j++) {
      const temp = list[j]
      if (temp > list[j + 1]) {
        list[j] = list[j + 1]
        list[j + 1] = temp
      }
    }
  }
  return list
}
const arr = [1,4,3,6,5,8,7,2,9,0]
console.log(bubbleSort(arr));